package name.jautzy.esi.server.model;

import java.util.HashMap;

import name.jautzy.cedb.model.Equipment;
import name.jautzy.cedb.model.Group;
import name.jautzy.esi.client.model.Fit;

public class FitModuleApply {
	public final static double[] stackCoef = {1.0,0.869119980800,0.570583143511,0.282955154023,0.105992649743,0.029991166533,0.006410183118,0.001034920483,0.000126212683,0.000011626754,0.000000809046};
	
	private Fit fit;
	private Equipment equip;
	private FitFactory factory;
	
	public FitModuleApply(Equipment equip, Group group, FitFactory factory) {
		this.equip = equip;
		this.factory = factory;
		this.fit = factory.getFit();
	}
	
	public void applyAfterburner () {
		if (fit.hasBooster())
			return;
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double sigBonus = 1.0+FitFactory.convertDouble(attributes.get("signatureRadiusBonus"))/100.0;
		double duration = FitFactory.convertDouble(attributes.get("duration"))/1000.0;
		double veloFactor = FitFactory.convertDouble(attributes.get("speedFactor"))/100.0;
		double capNeed = FitFactory.convertDouble(attributes.get("capacitorNeed"));
		if (sigBonus == 1.0) {//afterburner
			duration *= factory.getAfterburnerDurationBonus();
			veloFactor *= factory.getAftSpeedBonus();
		} else {
			capNeed *=factory.getMwdCapNeedBonus();
			sigBonus *=factory.getMwdSigBonus();
		}
		
		
		fit.setBooster(true);
		fit.setBoostVeloFactor(veloFactor);
		fit.setBoostRadiusFactor(sigBonus);
		fit.setBoostedMass(FitFactory.convertDouble(attributes.get("massAddition")));
		fit.setBoostCapUsage(capNeed/duration);
		fit.setBoostMass(FitFactory.convertDouble(attributes.get("speedBoostFactor")));
		factory.addCorrectionNoStack("Capacitor",FitFactory.convertDouble(attributes.get("capacitorCapacityMultiplier"))-1.0);
	}
	
	public void applyArmorCoating() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double armorHp = FitFactory.convertDouble(attributes.get("armorHPMultiplier"));
		double em = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("emDamageResistanceBonus"))/100.0;
		double ex = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("explosiveDamageResistanceBonus"))/100.0;
		double ki = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("kineticDamageResistanceBonus"))/100.0;
		double th = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("thermalDamageResistanceBonus"))/100.0;
		if (armorHp!=0)
			factory.addCorrectionNoStack("ArmorHP",armorHp-1.0);
		if (em!=0)
			factory.addCorrection("EmAR", em);
		if (ex!=0)
			factory.addCorrection("ExAR", ex);
		if (ki!=0)
			factory.addCorrection("KiAR", ki);
		if (th!=0)
			factory.addCorrection("ThAR", th);
	}
	
	public void applyArmorHardener() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		double em = FitFactory.convertDouble(attributes.get("emDamageResistanceBonus"))/100.0;
		double ex = FitFactory.convertDouble(attributes.get("explosiveDamageResistanceBonus"))/100.0;
		double ki = FitFactory.convertDouble(attributes.get("kineticDamageResistanceBonus"))/100.0;
		double th = FitFactory.convertDouble(attributes.get("thermalDamageResistanceBonus"))/100.0;
		if (em!=0)
			factory.addCorrection("EmAR", em);
		if (ex!=0)
			factory.addCorrection("ExAR", ex);
		if (ki!=0)
			factory.addCorrection("KiAR", ki);
		if (th!=0)
			factory.addCorrection("ThAR", th);
	}
	
	public void applyArmorPlatingEnergized() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double armorHp = FitFactory.convertDouble(attributes.get("armorHPMultiplier"));
		double em = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("emDamageResistanceBonus"))/100.0;
		double ex = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("explosiveDamageResistanceBonus"))/100.0;
		double ki = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("kineticDamageResistanceBonus"))/100.0;
		double th = factory.getPassiveArmorHardenerBonus()*FitFactory.convertDouble(attributes.get("thermalDamageResistanceBonus"))/100.0;
		if (armorHp!=0)
			factory.addCorrectionNoStack("ArmorHP",armorHp-1.0);
		if (em!=0)
			factory.addCorrection("EmAR", em);
		if (ex!=0)
			factory.addCorrection("ExAR", ex);
		if (ki!=0)
			factory.addCorrection("KiAR", ki);
		if (th!=0)
			factory.addCorrection("ThAR", th);
	}
	
	public void applyArmorReinforcer() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		fit.addArmorHP(FitFactory.convertDouble(attributes.get("armorHPBonusAdd")));
		fit.addMass(FitFactory.convertDouble(attributes.get("massAddition")));
	}
	
	public void applyArmorRepairProjector() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,1,factory.getRemArmorPowerNeedBonus());
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage*factory.getRemArmorCapNeedBonus());
		fit.setRemoteArmor(true);
	}
	
	public void applyArmorRepairUnit() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double duration = attributes.get("duration")/1000.0;
		double capUsage = attributes.get("capacitorNeed")/duration*factory.getArmorRepairCapNeedBonus();
		fit.addCapUsage(capUsage);
		fit.setArmorRepairDuration(1.0);
		fit.addArmorRepair(attributes.get("armorDamageAmount")/duration);
	}
	
	public void applyAutomatedTargetingSystem() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
	}
	
	public void applyAuxiliaryPowerCore() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		fit.addMaxPower(attributes.get("powerIncrease"));
	}
	
	public void applyBallisticControlsystem () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("MissileRof", FitFactory.convertDouble(attributes.get("speedMultiplier"))-1.0 );
		factory.addCorrection("MissileAlpha", FitFactory.convertDouble(attributes.get("missileDamageMultiplierBonus"))-1.0 );
	}
	
	public void applyCPUEnhancer() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrectionNoStack("MaxCpu", FitFactory.convertDouble(attributes.get("cpuMultiplier"))-1.0);
	}
	
	public void applyCapacitorBattery() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		fit.addCapacitor(attributes.get("capacitorBonus"));
	}
	
	public void applyCapacitorBooster() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyCapacitorPowerRelay() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		factory.addCorrectionNoStack("ShieldBoost", FitFactory.convertDouble(attributes.get("shieldBoostMultiplier"))/100.0);
		factory.addCorrectionNoStack("CapRechargeTime", FitFactory.convertDouble(attributes.get("capacitorRechargeRateMultiplier"))-1.0);
	}
	
	public void applyCapacitorFluxCoil() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		factory.addCorrectionNoStack("Capacitor", FitFactory.convertDouble(attributes.get("capacitorCapacityMultiplier"))-1.0);
		factory.addCorrectionNoStack("CapRechargeTime", FitFactory.convertDouble(attributes.get("capacitorRechargeRateMultiplier"))-1.0);
	}
	
	public void applyCapacitorRecharger() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		factory.addCorrectionNoStack("CapRechargeTime", FitFactory.convertDouble(attributes.get("capacitorRechargeRateMultiplier"))-1.0);
	}
	
	public void applyCargoScanner () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyCynosuralField () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		fit.setCynosural(true);
	}
	
	public void applyCloakingDevice () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		double scanBonus = FitFactory.convertDouble(attributes.get("scanResolutionMultiplier"));
		if (scanBonus!=0)
			factory.addCorrectionNoStack("ScanResolution", scanBonus-1.0);
		if (equip.getName().contains("Covert")) {
			fit.addPower(1);
			fit.setCloak(true);	
		}
		else {
			addRessources(attributes);
		}
		
	}
	
	public void applyDamageControl () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		double armor = attributes.get("armorEmDamageResonance")-1.0;
		double shield = attributes.get("shieldEmDamageResonance")-1.0;
		double hull = attributes.get("hullEmDamageResonance")-1.0;
		factory.addCorrectionNoStack("EmAR", armor);
		factory.addCorrectionNoStack("ExAR", armor);
		factory.addCorrectionNoStack("KiAR", armor);
		factory.addCorrectionNoStack("ThAR", armor);
		factory.addCorrectionNoStack("EmSR", shield);
		factory.addCorrectionNoStack("ExSR", shield);
		factory.addCorrectionNoStack("KiSR", shield);
		factory.addCorrectionNoStack("ThSR", shield);
		factory.addCorrectionNoStack("StructResonance", hull);
	}
	
	public void applyDataMiners () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyDroneControlRangeModule () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		
		fit.addDroneRange(attributes.get("droneRangeBonus"));
	}
	
	public void applyDroneControlUnit () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		
		fit.addNbDrones(FitFactory.convertLong(attributes.get("maxActiveDroneBonus")));
	}
	
	public void applyDroneNavigationComputer () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyDroneTrackingModules () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		
		factory.addCorrection("DroneRange", attributes.get("maxRangeMultiplier")-1.0);
		factory.addCorrection("DroneTracking", attributes.get("trackingSpeedMultiplier")-1.0);
	}
	
	public void applyECCM () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		
		double bonusM = attributes.get("scanMagnetometricStrengthPercent");
		double bonusR = attributes.get("scanRadarStrengthPercent");
		double bonusL = attributes.get("scanLadarStrengthPercent");
		double bonusG = attributes.get("scanGravimetricStrengthPercent");
		double bonus = Math.max(bonusM, bonusR);
		bonus = Math.max(bonus, bonusL);
		bonus = Math.max(bonus, bonusG);
		
		factory.addCorrection("SensorStrength", bonus/100.0);
	}
	
	public void applyECM () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage*factory.geteCMCapNeedBonus());
		
		fit.setEcm(true);
	}
	
	public void applyECMBurst () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyECMStabilizer () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyEnergyDestabilizer () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		fit.setNeutra(true);
	}
	
	public void applyEnergyTransferArray () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,1,factory.getRemEnergyPowerNeedBonus());
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage*factory.getRemEnergyCapNeedBonus());
	}
	
	public void applyEnergyVampire () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		fit.setNos(true);
	}
	
	public void applyExpandedCargohold () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		
		factory.addCorrectionNoStack("Cargohold", attributes.get("cargoCapacityMultiplier")-1.0);
		factory.addCorrectionNoStack("StructHP", attributes.get("structureHPMultiplier")-1.0);
		factory.addCorrectionNoStack("Velocity", attributes.get("maxVelocityBonus")-1.0);
	}
	
	public void applyFrequencyMiningLaser () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyGangCoordinator () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyGasCloudHarvester () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyGyrostabilizer () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("TurretAlpha",attributes.get("damageMultiplier")-1.0);
		factory.addCorrection("TurretRof",attributes.get("speedMultiplier")-1.0);
	}
	
	public void applyHeatSink () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("TurretAlpha",attributes.get("damageMultiplier")-1.0);
		factory.addCorrection("TurretRof",attributes.get("speedMultiplier")-1.0);
	}
	
	public void applyHullRepairUnit () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
	}
	
	public void applyInertiaStabilizer () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("Agility",FitFactory.convertDouble(attributes.get("agilityMultiplier"))/100.0);
		factory.addCorrectionNoStack("Signature", FitFactory.convertDouble(attributes.get("signatureRadiusBonus"))/100.0);
	}
	
	public void applyInterdictionSphereLauncher () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		fit.setScramble(true);
	}
	
	public void applyJumpPortalGenerator () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyMagneticFieldStabilizer () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("TurretAlpha",attributes.get("damageMultiplier")-1.0);
		factory.addCorrection("TurretRof",attributes.get("speedMultiplier")-1.0);
	}
	
	public void applyMiningLaser () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyMiningUpgrade() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyNanofiberInternalStructure () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("Agility",FitFactory.convertDouble(attributes.get("agilityMultiplier"))/100.0);
		factory.addCorrection("Velocity", FitFactory.convertDouble(attributes.get("implantBonusVelocity"))/100.0);
		factory.addCorrectionNoStack("StructHP", FitFactory.convertDouble(attributes.get("structureHPMultiplier"))-1.0);
	}
	
	public void applyOverdriveInjectorSystem () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("Agility",FitFactory.convertDouble(attributes.get("agilityMultiplier"))/100.0);
		factory.addCorrection("Velocity", FitFactory.convertDouble(attributes.get("implantBonusVelocity"))/100.0);
		factory.addCorrectionNoStack("Cargohold", FitFactory.convertDouble(attributes.get("cargoCapacityMultiplier"))-1.0);
	}
	
	public void applyPassiveTargetingSystem() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
	}
	
	public void applyProjectedECCM() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
	}
	
	public void applyPowerDiagnosticSystem () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		factory.addCorrectionNoStack("ShieldRechTime",FitFactory.convertDouble(attributes.get("shieldRechargeRateMultiplier"))-1.0);
		factory.addCorrectionNoStack("CapRechargeTime",FitFactory.convertDouble(attributes.get("capacitorRechargeRateMultiplier"))-1.0);
		factory.addCorrectionNoStack("MaxPower",FitFactory.convertDouble(attributes.get("powerOutputMultiplier"))-1.0);
		factory.addCorrectionNoStack("ShieldHP",FitFactory.convertDouble(attributes.get("shieldCapacityMultiplier"))-1.0);
		factory.addCorrectionNoStack("Capacitor",FitFactory.convertDouble(attributes.get("capacitorCapacityMultiplier"))-1.0);
	}
	
	public void applyReactorControlUnit () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		factory.addCorrectionNoStack("MaxPower",FitFactory.convertDouble(attributes.get("powerOutputMultiplier"))-1.0);
	}
	
	public void applyReinforcedBulkhead () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrectionNoStack("StructHP",FitFactory.convertDouble(attributes.get("structureHPMultiplier"))-1.0);
		factory.addCorrectionNoStack("Velocity",FitFactory.convertDouble(attributes.get("maxVelocityBonus"))-1.0);
	}
	
	public void applyRemoteECMBurst() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
	}
	
	public void applyRemoteHullRepairer() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage*factory.getRemHullCapNeedBonus());
	}
	
	public void applyRemoteSensorBooster() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
	}
	
	public void applyRemoteSensorDamper() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage*factory.getSensorCapNeedBonus());
		fit.setDamp(true);
	}
	
	public void applyRigArmor() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double vmalus = FitFactory.convertDouble(attributes.get("drawback"))/100.0*factory.getRigDrawbackReduction();
		factory.addCorrection("Velocity", vmalus);
		
		double thb = FitFactory.convertDouble(attributes.get("thermalDamageResistanceBonus"))/100.0;
		double kib = FitFactory.convertDouble(attributes.get("kineticDamageResistanceBonus"))/100.0;
		double emb = FitFactory.convertDouble(attributes.get("emDamageResistanceBonus"))/100.0;
		double exb = FitFactory.convertDouble(attributes.get("explosiveDamageResistanceBonus"))/100.0;
		double repb = FitFactory.convertDouble(attributes.get("repairBonus"))/100.0; 
		double repdurb = FitFactory.convertDouble(attributes.get("durationSkillBonus"))/100.0; 
		double rem = FitFactory.convertDouble(attributes.get("capNeedBonus"))/100.0; 
		double hpb = FitFactory.convertDouble(attributes.get("armorHpBonus"))/100.0; 
		
		if (thb!=0)
			factory.addCorrection("ThAR", thb);
		if (kib!=0)
			factory.addCorrection("KiAR", kib);
		if (emb!=0)
			factory.addCorrection("EmAR", emb);
		if (exb!=0)
			factory.addCorrection("ExAR", exb);
		if (repb!=0)
			factory.addCorrection("ArmorRepair", repb);
		if (repdurb!=0) {
			factory.addCorrection("ArmorRepairDuration", repdurb);
			double sbc = factory.getArmorRepairCapNeedBonus();
			factory.setArmorRepairCapNeedBonus(sbc/(1+repdurb));
		}
		if (rem!=0)
			factory.correctRemArmorCapNeedBonus(1.0+rem);
		if (hpb!=0)
			factory.addCorrectionNoStack("ArmorHP",hpb);	
	}
	
	public void applyRigAstronautic() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double vmalus = FitFactory.convertDouble(attributes.get("drawback"))/100.0*factory.getRigDrawbackReduction();
		factory.addCorrectionNoStack("ArmorHP", vmalus);
		
		double vb = FitFactory.convertDouble(attributes.get("velocityBonus"))/100.0 + FitFactory.convertDouble(attributes.get("implantBonusVelocity"))/100.0;
		double cb = FitFactory.convertDouble(attributes.get("cargoCapacityBonus"))/100.0;
		double capBonus = FitFactory.convertDouble(attributes.get("capNeedBonus"))/100.0;
		double durBonus = FitFactory.convertDouble(attributes.get("durationBonus"))/100.0;
		double agilBonus = FitFactory.convertDouble(attributes.get("agilityBonus"))/100.0 + FitFactory.convertDouble(attributes.get("agilityMultiplier"))/100.0 ;
		if (vb!=0)
			factory.addCorrection("Velocity", vb);
		if (cb!=0)
			factory.addCorrection("Cargohold", cb);
		if (capBonus!=0)
			factory.addCorrectionNoStack("BoostCapUsage", capBonus);
		if (durBonus!=0)
			factory.addCorrectionNoStack("BoostCapUsage", -1.0*durBonus/(1+durBonus));
		if (agilBonus!=0)
			factory.addCorrection("Agility", agilBonus);
	}
	
	public void applyRigDrones() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double cmalus = FitFactory.convertDouble(attributes.get("drawback"))/100.0*factory.getRigDrawbackReduction();
		factory.addCorrectionNoStack("MaxCpu", cmalus);
		
		double range = FitFactory.convertDouble(attributes.get("droneRangeBonus"))/100.0;
		if (range!=0)
			fit.addDroneRange(range);
		double dmg = FitFactory.convertDouble(attributes.get("damageMultiplierBonus"))/100.0;
		if (dmg!=0)
			factory.addCorrection("DroneAlpha", dmg);
	}
	
	public void applyRigElectronics() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double ecmCap = FitFactory.convertDouble(attributes.get("capNeedBonus"))/100.0;
		
		if (ecmCap!=0)
			factory.correcteCMCapNeedBonus(1.0+ecmCap);
	}
	
	public void applyRigElectronicsSuperiority() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double smalus = FitFactory.convertDouble(attributes.get("drawback"))/100.0*factory.getRigDrawbackReduction();
		factory.addCorrectionNoStack("ShieldHP", smalus);
		
		double scanReso =  FitFactory.convertDouble(attributes.get("scanResolutionMultiplier"));
		if (scanReso!=0)
			factory.addCorrection("ScanResolution",scanReso-1.0);
		
		double targetRange =  FitFactory.convertDouble(attributes.get("maxTargetRangeMultiplier"));
		if (targetRange!=0)
			factory.addCorrection("TargetRange",targetRange-1.0);
	}
		
	public void applyRigEnergyGrid() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double powerb = FitFactory.convertDouble(attributes.get("powerEngineeringOutputBonus"))/100.0;
		double caprechb = FitFactory.convertDouble(attributes.get("capRechargeBonus"))/100.0;
		double capneedb = FitFactory.convertDouble(attributes.get("capNeedBonus"))/100.0;
		double cpuneedb = FitFactory.convertDouble(attributes.get("cpuNeedBonus"))/100.0;
		double capb = FitFactory.convertDouble(attributes.get("capacitorCapacityBonus"))/100.0;
		
		if (powerb!=0)
			factory.addCorrectionNoStack("MaxPower", powerb);
		if (caprechb!=0)
			factory.addCorrectionNoStack("CapRecharcheTime", caprechb);
		if (capneedb!=0)
			factory.setRemEnergyCapNeedBonus(factory.getRemEnergyCapNeedBonus()*(1-capneedb));
		if (cpuneedb!=0)
			factory.setGridUpgradeCpuNeedBonus(factory.getGridUpgradeCpuNeedBonus()*(1-cpuneedb));
		if (capb!=0)
			factory.addCorrectionNoStack("Capacitor",capb);
	}
	
	public void applyRigHybridWeapon () {
		applyRigProjectileWeapon();
	}
	
	public void applyRigEnergyWeapon () {
		applyRigProjectileWeapon();
	}
	
	public void applyRigProjectileWeapon () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double tpb = factory.getTurretPowerNeedBonus();
		tpb*=1.0+FitFactory.convertDouble(attributes.get("drawback"))*factory.getRigDrawbackReduction()/100.0;
		factory.setTurretPowerNeedBonus(tpb);
		
		double cpub = FitFactory.convertDouble(attributes.get("cpuNeedBonus"))/100.0;
		double capb = FitFactory.convertDouble(attributes.get("capNeedBonus"))/100.0;
		double rofb = FitFactory.convertDouble(attributes.get("speedMultiplier"));
		if (rofb!=0)
			rofb = rofb-1.0;
		double falloffb = FitFactory.convertDouble(attributes.get("falloffbonus"))/100.0;
		double dmgb = FitFactory.convertDouble(attributes.get("damageMultiplier"));
		if (dmgb!=0)
			dmgb = dmgb-1.0;
		double trackb = FitFactory.convertDouble(attributes.get("trackingSpeedMultiplier"));
		if (trackb!=0)
			trackb = trackb-1.0;
		double optib = FitFactory.convertDouble(attributes.get("maxRangeBonus"))/100.0;
		
		if (cpub!=0)
			factory.setTurretCpuNeedBonus(factory.getTurretCpuNeedBonus()*(1.0+cpub));
		if (capb!=0)
			factory.setTurretCapNeedBonus(factory.getTurretCapNeedBonus()*(1.0+capb));
		if (rofb!=0)
			factory.addCorrection("TurretRof", rofb);
		if (falloffb!=0)
			factory.addCorrection("TurretFalloff", falloffb);
		if (dmgb!=0)
			factory.addCorrection("TurretAlpha", dmgb);
		if (trackb!=0)
			factory.addCorrection("TurretTracking", trackb);
		if (optib!=0)
			factory.addCorrection("TurretOptimal", optib);
		
		
	}
	
	public void applyRigLauncher() {	
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		double lcb = factory.getLauncherCpuNeedBonus();
		lcb*=1.0+FitFactory.convertDouble(attributes.get("drawback"))*factory.getRigDrawbackReduction()/100.0;
		factory.setLauncherCpuNeedBonus(lcb);
		
		double rofb = FitFactory.convertDouble(attributes.get("speedMultiplier"));
		if (rofb!=0)
			rofb = rofb - 1.0;
		double missvelob = FitFactory.convertDouble(attributes.get("speedFactor"))/100.0;
		double missftb = FitFactory.convertDouble(attributes.get("maxFlightTimeBonus"))/100.0;
		double dmgb = FitFactory.convertDouble(attributes.get("missileDamageMultiplierBonus"));
		if (dmgb!=0)
			dmgb = dmgb - 1.0;
		double mevb = FitFactory.convertDouble(attributes.get("aoeVelocityBonus"))/100.0;
		double merb = FitFactory.convertDouble(attributes.get("aoeCloudSizeBonus"))/100.0;
		
		if (rofb!=0)
			factory.addCorrection("MissileRof", rofb);
		if (missvelob!=0)
			factory.addCorrection("MissileVelocity", missvelob);
		if (missftb!=0)
			factory.addCorrectionNoStack("MissileFlightTime", missftb);
		if (dmgb!=0)
			factory.addCorrection("MissileAlpha", dmgb);
		if (mevb!=0)
			factory.addCorrectionNoStack("MissileExploVelocity", mevb);
		if (merb!=0)
			factory.addCorrectionNoStack("MissileExploRadius", merb);
	}
	
	public void applyRigShield() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRig(attributes);
		
		double malus = factory.getRigDrawbackReduction()*attributes.get("drawback")/100.0;
		factory.addCorrection("Signature", malus);
		
		double thb = FitFactory.convertDouble(attributes.get("thermalDamageResistanceBonus"))/100.0;
		double kib = FitFactory.convertDouble(attributes.get("kineticDamageResistanceBonus"))/100.0;
		double emb = FitFactory.convertDouble(attributes.get("emDamageResistanceBonus"))/100.0;
		double exb = FitFactory.convertDouble(attributes.get("explosiveDamageResistanceBonus"))/100.0;
		double hpb = FitFactory.convertDouble(attributes.get("shieldCapacityBonus"))/100.0;
		double rechb = FitFactory.convertDouble(attributes.get("rechargeratebonus"))/100.0;
		double powerb = FitFactory.convertDouble(attributes.get("powerNeedBonus"))/100.0;
		double shieldboostcapb = FitFactory.convertDouble(attributes.get("shieldBoostCapacitorBonus"))/100.0;
		double durb = FitFactory.convertDouble(attributes.get("durationSkillBonus"))/100.0;
		
		if (thb!=0)
			factory.addCorrection("ThSR", thb);
		if (kib!=0)
			factory.addCorrection("KiSR", kib);
		if (emb!=0)
			factory.addCorrection("EmSR", emb);
		if (exb!=0)
			factory.addCorrection("ExSR", exb);
		if (hpb!=0)
			factory.addCorrectionNoStack("ShieldHP", hpb);
		if (rechb!=0) 
			factory.addCorrectionNoStack("ShieldRechTime", rechb);
			
		if (powerb!=0) {
			double power = factory.getShieldUpgradePowerNeedBonus();
			factory.setShieldUpgradePowerNeedBonus(power*(1+powerb));
		}
		
		if (shieldboostcapb!=0) {
			double sbc = factory.getShieldBoosterCapNeedBonus();
			factory.setShieldBoosterCapNeedBonus(sbc*(1+shieldboostcapb));
		}	
		
		if (durb!=0) {
			factory.addCorrectionNoStack("ShieldBoostDuration",durb);
			double sbc = factory.getShieldBoosterCapNeedBonus();
			factory.setShieldBoosterCapNeedBonus(sbc/(1+durb));
		}
	}
		
	public void applyScanProbeLauncher() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applySensorBooster() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		Equipment ammo = equip.getAmmo();
		double maxRangeBonus = attributes.get("maxTargetRangeBonus")/100.0;
		double scanResoBonus = attributes.get("scanResolutionBonus")/100.0;
		if (ammo != null) {
			if (ammo.getName().equals("Scan Resolution")) {
				maxRangeBonus = 0;
				scanResoBonus *=2;
			}
			else if (ammo.getName().equals("Targeting Range")) {
				maxRangeBonus *= 2;
				scanResoBonus *= 0;
			}
		}	
		factory.addCorrectionNoStack("ScanResolution", scanResoBonus);
		factory.addCorrectionNoStack("TargetRange", maxRangeBonus);	
	}
	
	public void applySensorBackupArray() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getSensorUpgradeCpuNeedBonus(),1);
		factory.addCorrection("SensorStrength",FitFactory.convertDouble(attributes.get("scanGravimetricStrengthPercent"))/100.0);
		factory.addCorrection("SensorStrength",FitFactory.convertDouble(attributes.get("scanLadarStrengthPercent"))/100.0);
		factory.addCorrection("SensorStrength",FitFactory.convertDouble(attributes.get("scanRadarStrengthPercent"))/100.0);
		factory.addCorrection("SensorStrength",FitFactory.convertDouble(attributes.get("scanMagnetometricStrengthPercent"))/100.0);
	}
	
	public void applyShieldAmplifier() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		
		double em = factory.getPassiveShieldHardenerBonus()*FitFactory.convertDouble(attributes.get("emDamageResistanceBonus"))/100.0;
		double ex = factory.getPassiveShieldHardenerBonus()*FitFactory.convertDouble(attributes.get("explosiveDamageResistanceBonus"))/100.0;
		double ki = factory.getPassiveShieldHardenerBonus()*FitFactory.convertDouble(attributes.get("kineticDamageResistanceBonus"))/100.0;
		double th = factory.getPassiveShieldHardenerBonus()*FitFactory.convertDouble(attributes.get("thermalDamageResistanceBonus"))/100.0;
		
		if (em!=0)
			factory.addCorrection("EmSR", em);
		if (ex!=0)
			factory.addCorrection("ExSR", ex);
		if (ki!=0)
			factory.addCorrection("KiSR", ki);
		if (th!=0)
			factory.addCorrection("ThSR", th);
	}
	
	public void applyShieldBoostAmplifier() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("ShieldBoost",attributes.get("shieldBoostMultiplier")/100.0);
	}
	
	public void applyShieldBooster() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double duration = attributes.get("duration")/1000.0;
		fit.setShieldBoostDuration(1.0);
		fit.addShieldBoost(attributes.get("shieldBonus")/duration);
		double capUsage = factory.getShieldBoosterCapNeedBonus()*attributes.get("capacitorNeed")/duration;
		fit.addCapUsage(capUsage);
	}
	
	public void applyShieldExtender () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,1,factory.getShieldUpgradePowerNeedBonus());
		fit.addShieldHP(attributes.get("capacityBonus"));	
		fit.addSignature(attributes.get("signatureRadiusAdd"));
	}
	
	public void applyShieldFluxCoil () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		factory.addCorrectionNoStack("ShieldRechTime", attributes.get("shieldRechargeRateMultiplier")-1.0);
		factory.addCorrectionNoStack("ShieldHP", attributes.get("shieldCapacityMultiplier")-1.0);
	}
	
	public void applyShieldHardener () {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		double em = FitFactory.convertDouble(attributes.get("emDamageResistanceBonus"))/100.0;
		double ex = FitFactory.convertDouble(attributes.get("explosiveDamageResistanceBonus"))/100.0;
		double ki = FitFactory.convertDouble(attributes.get("kineticDamageResistanceBonus"))/100.0;
		double th = FitFactory.convertDouble(attributes.get("thermalDamageResistanceBonus"))/100.0;
		if (em!=0)
			factory.addCorrection("EmSR", em);
		if (ex!=0)
			factory.addCorrection("ExSR", ex);
		if (ki!=0)
			factory.addCorrection("KiSR", ki);
		if (th!=0)
			factory.addCorrection("ThSR", th);
		
	}
	
	public void applyShieldPowerRelay() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getGridUpgradeCpuNeedBonus(),1);
		factory.addCorrectionNoStack("ShieldRechTime", attributes.get("shieldRechargeRateMultiplier")-1.0);
		factory.addCorrectionNoStack("CapRechargeTime", attributes.get("capacitorRechargeRateMultiplier")-1.0);
	}
	
	public void applyShieldRecharger() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,1,factory.getShieldUpgradePowerNeedBonus());
		factory.addCorrectionNoStack("ShieldRechTime", attributes.get("shieldRechargeRateMultiplier")-1.0);
	}
	
	public void applyShieldTransporter() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getRemShieldCpuNeedBonus(),1);
		double capUsage = factory.getRemShieldCapNeedBonus()*attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		fit.setRemoteShield(true);
	}
	
	public void applyShipScanner() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applySiegeModule() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applySignalAmplifier() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getSensorUpgradeCpuNeedBonus(),1);
		factory.addCorrection("TargetRange",attributes.get("maxTargetRangeBonus")/100.0 );
		factory.addCorrection("ScanResolution",attributes.get("scanResolutionBonus")/100.0 );
	}
	
	public void applySmartBomb() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes,factory.getTurretCpuNeedBonus(),1);
	}
	
	public void applyStasisWeb() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = factory.getScrambleWebCapNeedBonus()*attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		factory.addCorrectionNoStack("targetSpeedMod",attributes.get("speedFactor")/100.0);
		fit.addCapUsage(capUsage);
		fit.setWeb(true);
	}
	
	public void applyStripMiner() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
	}
	
	public void applySuperWeapon() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applySurveyScanner() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applySystemScanner() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyTargetPainter() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = factory.getPainterCapNeedBonus()*attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		factory.addCorrection("targetPaintMod",attributes.get("signatureRadiusBonus")/100.0);
		fit.addCapUsage(capUsage);
		fit.setPaint(true);
	}
	
	public void applyTrackingComputer() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);	
		double capUsage = attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		
		Equipment ammo = equip.getAmmo();
		double maxRangeBonus = attributes.get("maxRangeBonus")/100.0;
		double falloffBonus = attributes.get("falloffBonus")/100.0;
		double trackingSpeedBonus = attributes.get("trackingSpeedBonus")/100.0;
		if (ammo != null) {
			if (ammo.getName().equals("Optimal Range")) {
				maxRangeBonus *= 2;
				falloffBonus *=2;
				trackingSpeedBonus = 0;
			}
			else if (ammo.getName().equals("Tracking Speed")) {
				maxRangeBonus = 0;
				falloffBonus =0;
				trackingSpeedBonus *= 2;
			}
		}	
		factory.addCorrection("TurretFalloff",falloffBonus );
		factory.addCorrection("TurretOptimal",maxRangeBonus );
		factory.addCorrection("TurretTracking",trackingSpeedBonus);
		
	}
	
	public void applyTrackingDisruptor() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);	
		double capUsage = factory.getDisruptCapNeedBonus()*attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		fit.setTrackingDisrupt(true);
	}
	
	public void applyTrackingEnhancer() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		factory.addCorrection("TurretFalloff",attributes.get("falloffBonus")/100.0 );
		factory.addCorrection("TurretOptimal",attributes.get("maxRangeBonus")/100.0 );
		factory.addCorrection("TurretTracking",attributes.get("trackingSpeedBonus")/100.0 );
	}
	
	public void applyTrackingLink() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);	
	}
	
	public void applyTractorBeam() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyWarpCoreStabilizer() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
	}
	
	public void applyWarpDisruptFieldGenerator() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = factory.getScrambleWebCapNeedBonus()*attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		fit.setScramble(true);
	}
	
	public void applyWarpScrambler() {
		HashMap<String,Double> attributes = factory.getDao().getAttributesAsMapFor(equip);
		addRessources(attributes);
		double capUsage = factory.getScrambleCapNeedBonus()*factory.getScrambleWebCapNeedBonus()*attributes.get("capacitorNeed")/(attributes.get("duration")/1000.0);
		fit.addCapUsage(capUsage);
		fit.setScramble(true);
	}

    //helper methods
	private void addRig(HashMap<String,Double> attributes) {
		fit.addCalibration(FitFactory.convertLong(attributes.get("upgradeCost")));
	}
	
	private void addRessources(HashMap<String,Double> attributes, double cpuMod, double powerMod) {
		fit.addCpu(cpuMod*FitFactory.convertDouble(attributes.get("cpu")));
		fit.addPower(powerMod*FitFactory.convertDouble(attributes.get("power")));
	}
	
	private void addRessources(HashMap<String,Double> attributes) {
		addRessources(attributes, 1,1);
	}
	
}
